import java.util.function.Consumer;

/**
 * @ClassName Demo05
 * @Description TODO
 * @Author Li
 * @Date 2022/8/14 15:11
 * @ModifyDate 2022/8/14 15:11
 * @Version 1.0
 */
public class Demo05 {
    public static void main(String[] args) {
        String[] arr = {"张三,男", "李四,男", "小翠,女", "王二,男"};
        consumeString(
                s -> {
                    System.out.print("姓名:" +
                            s.substring(0, s.indexOf(",")));
                },
                s -> {
                    System.out.println(",性别:" +
                            s.substring(s.indexOf(",") + 1));
                },
                arr);
    }

    private static void consumeString(Consumer<String> c1,
                                      Consumer<String> c2,
                                      String[] arr) {
        for (String s : arr) {
            c1.andThen(c2).accept(s);
        }
    }
}
